Skip to content

fix(ng-dev): ensure sync-module-bazel uses correct paths when executed in nested directories#3512

Closed
alan-agius4 wants to merge 1 commit intoangular:mainfrom
alan-agius4:sync-bazel-cwd
Closed

fix(ng-dev): ensure sync-module-bazel uses correct paths when executed in nested directories#3512
alan-agius4 wants to merge 1 commit intoangular:mainfrom
alan-agius4:sync-bazel-cwd

Conversation

@alan-agius4
Copy link
Copy Markdown
Contributor

The cwd was not specified which resulted in incorrect execution path.

…d in nested directories

The cwd was not specified which resulted in incorrect execution path.
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request aims to fix an issue with incorrect paths when running sync-module-bazel from a nested directory. The changes correctly identify the areas that need modification (formatFiles and ChildProcess.spawnSync). However, the fix is incomplete because the rootDir variable is still initialized to the current working directory instead of the repository root. My review includes a comment with a suggestion to fully address the issue.

Comment on lines 70 to 73
ChildProcess.spawnSync('pnpm', ['bazel', 'mod', 'deps', '--lockfile_mode=update'], {
suppressErrorOnFailingExitCode: true,
cwd: rootDir,
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This change aims to fix execution from nested directories by setting cwd. However, as rootDir is initialized to process.cwd() on line 25, this change is ineffective because spawnSync already defaults to using the current working directory.

To achieve the goal of this PR, rootDir must point to the repository's root directory. This would also make the change on line 68 (using moduleBazelPath) work as intended when running from a nested directory.

A full fix would involve changing how rootDir is initialized at the start of the handler function. For example:

// At line 25
const rootDir = determineRepoBaseDirFromCwd();

While this change is outside the current diff, it is essential for this PR's stated goal to be met.

@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Apr 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant